package Database;

import java.sql.*;

public class Driver
{
	static final String USER = "root";
	static final String password = "980629";
	public Driver()
	{
		try
		{
			Class.forName("com.mysql.jdbc.Driver");
			Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", USER, password);
			Statement statement = connection.createStatement();

//			statement.executeUpdate("CREATE TABLE TEST_TABLE" +
//					" (id INT AUTO_INCREMENT PRIMARY KEY, " +
//					"name VARCHAR(100), " +
//					"age INT, "+
//					"occupation VARCHAR(50))DEFAULT CHARSET = utf8");
//			statement.executeUpdate("INSERT INTO test_table VALUES (4, 'cyf', 12, 'student' )");
			ResultSet resultSet = statement.executeQuery("SELECT * FROM test.test_table");
			while (resultSet.next())
			{
				String id = resultSet.getString("name");
				System.out.println(id);
			}
			statement.close();

			connection.close();
			System.out.println("ConnectionGo");
		}
		catch (ClassNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}

	}
}
